<template>
	<div>
		<section class="set">
			<first-change v-if='type==3'></first-change>
			<mima-change v-if='type==2'></mima-change>
			<mobile-change v-if='type==1'></mobile-change>
		</section>
	</div>
</template>
<script>
    const MobileChange = r => require.ensure([],()=>r(require("../components/MobileChange")))
    const MimaChange = r => require.ensure([],()=>r(require("../components/MimaChange")))
    const FirstChange = r => require.ensure([],()=>r(require("../components/FirstChange")))
	import {
		mapState,
	} from 'vuex'

	export default {
		data() {
			return {
				type: 0
			}
		},
		components: {
			MobileChange,
			MimaChange,
			FirstChange
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			beforeChange() {
				var that = this;
                var d = "sessionid=" + userInfo.sessionid + "&userid=" + userInfo.userid;
				this.axios.post(userInfo.hosturl + '/IOSApi/editpwd_before', d, {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}).then(function (data) {
					var data = data.data;
					if (data.result == 0) {
                        //1验证码新密码
                        //2旧密码新密码
                        //3新密码
                        that.type = data.data
					} else if (data.result == 1037) {
						loginout(1)
					} else {
						toast(data.error)
					}
				})
			}
        },
        created(){
           // console.log("father created")
        },
        //当引入keep-alive的时候，页面第一次进入，钩子的触发顺序created-> mounted-> activated，退出时触发deactivated。当再次进入（前进或者后退）时，只触发activated。
		activated() {
           // console.log("father activated")
			this.beforeChange()
        },
        mounted(){
            //console.log("father mounted")
        }
	}
</script>
